package br.ufla.pgcc.oomeasures.plugin.views;

import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.part.ViewPart;
import org.jfree.chart.JFreeChart;
import org.jfree.experimental.chart.swt.ChartComposite;

import br.ufla.pgcc.oomeasures.ItemMeasured;
import br.ufla.pgcc.oomeasures.plugin.chart.Chart;

public class ChartView extends ViewPart {
	public static final String ID = "br.ufla.pgcc.oomeasures.plugin.views.ChartView";
	private ChartComposite view;
	

	public void showChart(ItemMeasured itemMeasured) {
		Chart chart = new Chart();
		JFreeChart jFreechart = chart.createLineChart(itemMeasured);

		view.setChart(jFreechart);
		view.update();
	}
	
	/**
	 * This is a callback that will allow us to create the viewer and initialize
	 * it.
	 */
	public void createPartControl(Composite parent) {
		view = new ChartComposite(parent, SWT.NONE, null, true);
		view.pack();
	}

	/**
	 * Passing the focus request to the viewer's control.
	 */
	public void setFocus() {
		view.setFocus();
	}
}
